<%-- 
    Document   : index
    Created on : Nov 18, 2012, 11:40:04 PM
    Author     : BlueS
--%>

<%@page import="edu.fpt.dal.BudgetDAL"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Login Page</title>
        <link href="Theme/style.css" media="screen" rel="stylesheet" type="text/css">
    </head>
    <body>
        <div class="logo_holder"><img src="Image/logo.png" height="150" width="350" class="logo"></div>

    <center>
        <form action="index.jsp" method="POST">
            <div class="box">
                <h1>Sign In:</h1>
                <%
                    if ("POST".equals(request.getMethod())) {
                        if (BudgetDAL.checkLogin(request.getParameter("username"), request.getParameter("pass"))) {
                            HttpSession ses = request.getSession();
                            ses.setAttribute("pass", request.getParameter("pass"));
                            ses.setAttribute("user", request.getParameter("username"));
                            response.sendRedirect("Manager/manager.jsp");
                        } else {
                            out.println("<h3 style='color: red;'>Login Failed!</h3>");
                        }
                    }
                    if ("out".equals(request.getParameter("logout"))) {
                        HttpSession ses = request.getSession();
                        ses.invalidate();
                    }
                %>
                <label>
                    <span>Username</span>
                    <input type="text" class="input_text" name="username" id="email"/>
                </label>
                <label>
                    <span>Password</span>
                    <input type="password" class="input_text" name="pass" id="subject"/>
                </label>
                <label>
                    <input type="submit" class="button" value="Sign In" />
                    <a href="register.jsp"><input type="button" class="button" value="Resgister" /></a>
                </label>
            </div>
        </form>
    </center>
</body>
</html>
